package com.google.code.jtasks.connection;

import java.net.URL;
import java.util.HashMap;
import java.util.Map;

import com.google.code.jtasks.adapters.ITaskSystemAdapter;

/**
 * Models the settings required to connect to a {@link TaskRepository}.
 */
public final class TaskRepoConnectionSettings
{
	private final TaskRepoId repoId;
	private final ITaskSystemAdapter adapter;
	private final URL url;
	private final String userName;
	private final String password;
	private final Map<String, String> options;

	/**
	 * Constructs a new {@link TaskRepoConnectionSettings} instance.
	 * 
	 * @param repoId
	 *            the {@link TaskRepoId} that identifies the task repository this
	 *            {@link TaskRepoConnectionSettings} is for
	 * @param adapter
	 *            the {@link ITaskSystemAdapter} to use to interact with the task repository
	 * @param url
	 *            the {@link URL} to connect to the task repository at
	 * @param userName
	 *            the user name to authenticate to the task repository with
	 * @param password
	 *            the password to authenticate to the task repository with
	 */
	public TaskRepoConnectionSettings(TaskRepoId repoId, ITaskSystemAdapter adapter, URL url,
			String userName, String password)
	{
		this(repoId, adapter, url, userName, password, new HashMap<String, String>());
	}

	/**
	 * Constructs a new {@link TaskRepoConnectionSettings} instance.
	 * 
	 * @param repoId
	 *            the {@link TaskRepoId} that identifies the task repository this
	 *            {@link TaskRepoConnectionSettings} is for
	 * @param adapter
	 *            the {@link ITaskSystemAdapter} to use to interact with the task repository
	 * @param url
	 *            the {@link URL} to connect to the task repository at
	 * @param userName
	 *            the user name to authenticate to the task repository with
	 * @param password
	 *            the password to authenticate to the task repository with
	 * @param options
	 *            the {@link Map} of connection options to pass to XXX (generally non-standard and specific to
	 *            the task system)
	 */
	public TaskRepoConnectionSettings(TaskRepoId repoId, ITaskSystemAdapter adapter, URL url,
			String userName, String password, Map<String, String> options)
	{
		this.repoId = repoId;
		this.adapter = adapter;
		this.url = url;
		this.userName = userName;
		this.password = password;
		this.options = options;
	}

	/**
	 * @return the {@link TaskRepoId} that identifies the task repository this
	 *         {@link TaskRepoConnectionSettings} is for
	 */
	public TaskRepoId getTaskRepoId()
	{
		return repoId;
	}

	/**
	 * @return the {@link ITaskSystemAdapter} to use to interact with the task repository
	 */
	public ITaskSystemAdapter getAdapter()
	{
		return adapter;
	}

	/**
	 * @return the {@link URL} to connect to the task repository at
	 */
	public URL getUrl()
	{
		return url;
	}

	/**
	 * @return the user name to authenticate to the task repository with
	 */
	public String getUserName()
	{
		return userName;
	}

	/**
	 * @return the password to authenticate to the task repository with
	 */
	public String getPassword()
	{
		return password;
	}

	/**
	 * @return the {@link Map} of connection options to pass to XXX (generally non-standard and specific to
	 *         the task system)
	 */
	public Map<String, String> getOptions()
	{
		return options;
	}
}
